
// server.js
const express = require('express');
const app = express();
const port = 3000;

// 根路由
app.get('/', (req, res) => {
  res.send('Hello World!');
});

// 错误处理中间件
app.use((err, req, res, next) => {
  console.error(err.stack);
  res.status(500).send('Server Error!');
});

// 启动服务器
app.listen(port, () => {
  console.log(`Server running at http://localhost:${port}`);
});